package com.kingdee.eas.crm.market.client;

import java.awt.Color;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import javax.swing.JComponent;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.kdf.table.BasicView;
import com.kingdee.bos.ctrl.kdf.table.ICell;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTDefaultCellEditor;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.table.event.KDTEditEvent;
import com.kingdee.bos.ctrl.kdf.table.event.KDTMouseEvent;
import com.kingdee.bos.ctrl.swing.KDComboBox;
import com.kingdee.bos.ctrl.swing.KDDatePicker;
import com.kingdee.bos.ctrl.swing.KDFormattedTextField;
import com.kingdee.bos.ctrl.swing.KDPromptBox;
import com.kingdee.bos.ctrl.swing.KDSpinner;
import com.kingdee.bos.ctrl.swing.KDTextField;
import com.kingdee.bos.ctrl.swing.event.DataChangeEvent;
import com.kingdee.bos.ctrl.swing.event.DataChangeListener;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.basedata.org.FullOrgUnitFactory;
import com.kingdee.eas.basedata.org.FullOrgUnitInfo;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.crm.base.CostFeeFactory;
import com.kingdee.eas.crm.base.CostFeeInfo;
import com.kingdee.eas.crm.market.ChannelTypeCollection;
import com.kingdee.eas.crm.market.ChannelTypeFactory;
import com.kingdee.eas.crm.market.ChannelTypeInfo;
import com.kingdee.eas.crm.market.ChannelTypeTreeFactory;
import com.kingdee.eas.crm.market.ChannelTypeTreeInfo;
import com.kingdee.eas.crm.market.MarketPlanCollection;
import com.kingdee.eas.crm.market.MarketPlanEntryCollection;
import com.kingdee.eas.crm.market.MarketPlanEntryInfo;
import com.kingdee.eas.crm.market.MarketPlanEntrySellPlanEntryCollection;
import com.kingdee.eas.crm.market.MarketPlanEntrySellPlanEntryInfo;
import com.kingdee.eas.crm.market.MarketPlanFactory;
import com.kingdee.eas.crm.market.MarketPlanInfo;
import com.kingdee.eas.crm.market.ThemeEnum;
import com.kingdee.eas.fdc.basecrm.CRMHelper;
import com.kingdee.eas.fdc.basecrm.client.CRMClientHelper;
import com.kingdee.eas.fdc.basedata.FDCBillStateEnum;
import com.kingdee.eas.fdc.basedata.FDCHelper;
import com.kingdee.eas.fdc.basedata.client.FDCMsgBox;
import com.kingdee.eas.fdc.basedata.util.KDDetailedArea;
import com.kingdee.eas.fdc.basedata.util.KDDetailedAreaDialog;
import com.kingdee.eas.fdc.market.client.TableUtils;
import com.kingdee.eas.fdc.market.client.VerifyInputUtil;
import com.kingdee.eas.fdc.sellhouse.SellProjectFactory;
import com.kingdee.eas.fdc.sellhouse.SellProjectInfo;
import com.kingdee.eas.fdc.sellhouse.client.CommerceHelper;
import com.kingdee.eas.framework.ICoreBase;
import com.kingdee.eas.rptclient.newrpt.util.MsgBox;
import com.kingdee.eas.util.SysUtil;


public class MarketPlanEditUI extends AbstractMarketPlanEditUI
{

            public MarketPlanEditUI()throws Exception
            {
/* 108*/        isWarning = false;
/*1049*/        now = null;
/*1050*/        sellProjectId = null;
            }

            public void onLoad()
                throws Exception
            {
/* 122*/        filesType();
/* 124*/        super.onLoad();
/* 126*/        setPreferredSize(getMaximumSize());
/* 128*/        txtPlanYear.setGroupingUsed(false);
/* 129*/        txtPlanYear.setDataType(0);
/* 132*/        SpinnerNumberModel model = new SpinnerNumberModel(editData.getPlanMonth(), 1, 12, 1);
/* 133*/        kDPlanMonth.setModel(model);
/* 135*/        menuTable1.setVisible(false);
/* 136*/        btnAddLine.setVisible(false);
/* 137*/        btnInsertLine.setVisible(false);
/* 138*/        btnRemoveLine.setVisible(false);
/* 139*/        actionCreateFrom.setVisible(false);
/* 140*/        actionTraceDown.setVisible(false);
/* 141*/        actionTraceUp.setVisible(false);
/* 142*/        actionCopy.setVisible(false);
/* 143*/        actionCopyFrom.setVisible(false);
/* 144*/        chkMenuItemSubmitAndAddNew.setVisible(false);
/* 145*/        chkMenuItemSubmitAndAddNew.setSelected(false);
/* 146*/        chkMenuItemSubmitAndPrint.setVisible(false);
/* 147*/        chkMenuItemSubmitAndPrint.setSelected(false);
/* 148*/        menuBiz.setVisible(false);
/* 149*/        menuSubmitOption.setVisible(false);
/* 151*/        actionAddNew.setVisible(false);
/* 152*/        prmtOrgUnit.setAccessAuthority(0);
/* 153*/        prmtSellProject.setAccessAuthority(0);
/* 154*/        prmtOrgUnit.setEnabled(false);
/* 155*/        prmtSellProject.setEnabled(false);
/* 157*/        CRMClientHelper.changeTableNumberFormat(tblMainPlan, new String[] {
/* 157*/            "planCost"
                });
            }

            public SelectorItemCollection getSelectors()
            {
/* 161*/        SelectorItemCollection sel = super.getSelectors();
/* 162*/        sel.add("entry.*");
/* 163*/        sel.add("entry.sellPlanEntry.*");
/* 164*/        sel.add("entry.sellPlanEntry.subject.*");
/* 165*/        sel.add("entry.sellPlanEntry.classify.*");
/* 166*/        sel.add("entry.sellPlanEntry.mediaName.*");
/* 167*/        sel.add("CU.*");
/* 168*/        return sel;
            }

            protected void setAuditButtonStatus(String oprtType)
            {
/* 171*/        super.setAuditButtonStatus(oprtType);
/* 172*/        if("VIEW".equals(oprtType))
                {
/* 173*/            btnAddTheme.setEnabled(false);
/* 174*/            btnAddProceed.setEnabled(false);
/* 175*/            btnDelProceed.setEnabled(false);
/* 176*/            btnDelTheme.setEnabled(false);
/* 177*/            btnChange.setEnabled(false);
                } else
                {
/* 179*/            btnAddTheme.setEnabled(true);
/* 180*/            btnAddProceed.setEnabled(true);
/* 181*/            btnDelProceed.setEnabled(true);
/* 182*/            btnDelTheme.setEnabled(true);
/* 183*/            btnChange.setEnabled(true);
                }
/* 186*/        if("ADDNEW".equals(oprtType))
                {
/* 187*/            txtPlanYear.setEnabled(true);
/* 188*/            kDPlanMonth.setEnabled(true);
                } else
                {
/* 190*/            txtPlanYear.setEnabled(false);
/* 191*/            kDPlanMonth.setEnabled(false);
                }
            }

            public void storeFields()
            {
/* 196*/        storeEntry();
/* 197*/        super.storeFields();
            }

            public void loadFields()
            {
/* 200*/        detachListeners();
/* 201*/        super.loadFields();
/* 202*/        setSaveActionStatus();
/* 204*/        int idx = idList.getCurrentIndex();
/* 205*/        if(idx >= 0)
/* 206*/            billIndex = (new StringBuilder("(")).append(idx + 1).append(")").toString();
/* 208*/        else
/* 208*/            billIndex = "";
/* 210*/        refreshUITitle();
/* 211*/        setAuditButtonStatus(getOprtState());
/* 213*/        loadEntry(editData.getEntry());
/* 214*/        attachListeners();
            }

            protected void verifyInputForSave()
                throws Exception
            {
/* 217*/        if(isWarning && FDCMsgBox.showConfirm2(this, "\u4E4B\u524D\u5B58\u5728\u672A\u5BA1\u6279\u7684\u4F01\u5212\u8BA1\u5212\uFF0C\u63D0\u4EA4\u5C06\u8986\u76D6\u8BE5\u8BA1\u5212\uFF0C\u662F\u5426\u7EE7\u7EED\uFF1F") != 0)
/* 219*/            SysUtil.abort();
/* 222*/        if(getNumberCtrl().isEnabled())
/* 223*/        VerifyInputUtil.verifyNull(this, txtNumber, "\u8BA1\u5212\u7F16\u53F7");
/* 225*/        VerifyInputUtil.verifyNull(this, txtNumber, "\u8BA1\u5212\u540D\u79F0");
/* 226*/        VerifyInputUtil.verifyNull(this, txtPlanYear, "\u8BA1\u5212\u5E74\u4EFD");
            }

            protected void verifyInputForSubmint()
                throws Exception
            {
/* 229*/        verifyInputForSave();
/* 230*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "theme");
/* 231*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "enDescribe");
/* 232*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "proceeding");
/* 233*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "subject");
/* 234*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "classify");
/* 235*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "mediaName");
/* 236*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "startTime");
/* 237*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "endTime");
/* 238*/        VerifyInputUtil.verifyKDTColumnNull(this, tblMainPlan, "planCost");
            }

            public void storeEntry()
            {
/* 244*/        editData.getEntry().clear();
/* 245*/        for(int i = 0; i < tblMainPlan.getRowCount(); i++)
                {
/* 246*/            IRow row = tblMainPlan.getRow(i);
/* 247*/            MarketPlanEntryInfo entry = (MarketPlanEntryInfo)row.getCell("theme").getUserObject();
/* 248*/            MarketPlanEntrySellPlanEntryInfo sellPlanInfo = (MarketPlanEntrySellPlanEntryInfo)row.getUserObject();
/* 249*/            if(tblMainPlan.getCell(i, "proceeding").getValue() != null)
                    {
/* 250*/                String proceeding = (String)tblMainPlan.getCell(i, "proceeding").getValue();
/* 251*/                sellPlanInfo.setProceeding(proceeding);
                    }
/* 253*/            if(tblMainPlan.getCell(i, "entryState").getValue() != null)
                    {
/* 254*/                ThemeEnum entryState = (ThemeEnum)tblMainPlan.getCell(i, "entryState").getValue();
/* 255*/                sellPlanInfo.setState(entryState);
                    }
/* 257*/            if(tblMainPlan.getCell(i, "mediaName").getValue() != null)
                    {
/* 258*/                ChannelTypeInfo mediaName = (ChannelTypeInfo)tblMainPlan.getCell(i, "mediaName").getValue();
/* 259*/                sellPlanInfo.setMediaName(mediaName);
                    }
/* 261*/            if(tblMainPlan.getCell(i, "classify").getValue() != null)
                    {
/* 262*/                ChannelTypeTreeInfo classifyInfo = (ChannelTypeTreeInfo)tblMainPlan.getCell(i, "classify").getValue();
/* 263*/                sellPlanInfo.setClassify(classifyInfo);
                    }
/* 265*/            if(tblMainPlan.getCell(i, "subject").getValue() != null)
                    {
/* 266*/                CostFeeInfo subjectInfo = (CostFeeInfo)tblMainPlan.getCell(i, "subject").getValue();
/* 267*/                sellPlanInfo.setSubject(subjectInfo);
                    }
/* 269*/            Date startTime = null;
/* 270*/            if(tblMainPlan.getCell(i, "startTime").getValue() != null)
                    {
/* 271*/                startTime = (Date)tblMainPlan.getCell(i, "startTime").getValue();
/* 272*/                sellPlanInfo.setStartTime(startTime);
                    }
/* 274*/            Date endTime = null;
/* 275*/            if(tblMainPlan.getCell(i, "endTime").getValue() != null)
                    {
/* 276*/                endTime = (Date)tblMainPlan.getCell(i, "endTime").getValue();
/* 277*/                sellPlanInfo.setEndTime(endTime);
                    }
/* 279*/            if(tblMainPlan.getCell(i, "quantity").getValue() != null)
                    {
/* 280*/                Object quantity = tblMainPlan.getCell(i, "quantity").getValue();
/* 281*/                int quan = Integer.parseInt(quantity.toString());
/* 282*/                sellPlanInfo.setQuantity(quan);
                    }
/* 284*/            BigDecimal planCost = FDCHelper.ZERO;
/* 285*/            if(tblMainPlan.getCell(i, "planCost").getValue() != null)
                    {
/* 286*/                planCost = (BigDecimal)tblMainPlan.getCell(i, "planCost").getValue();
/* 287*/                sellPlanInfo.setPlanCost(planCost);
                    }
/* 289*/            if(tblMainPlan.getCell(i, "remark").getValue() != null)
                    {
/* 290*/                String remark = (String)tblMainPlan.getCell(i, "remark").getValue();
/* 291*/                sellPlanInfo.setRemark(remark);
                    }
/* 294*/            if(editData.getEntry().containsObject(entry))
                    {
/* 295*/                entry.getSellPlanEntry().add(sellPlanInfo);
                    } else
                    {
/* 298*/                entry.getSellPlanEntry().clear();
/* 299*/                if(tblMainPlan.getCell(i, "themeState").getValue() != null)
                        {
/* 300*/                    ThemeEnum state = (ThemeEnum)tblMainPlan.getCell(i, "themeState").getValue();
/* 301*/                    entry.setState(state);
                        }
/* 303*/                if(tblMainPlan.getCell(i, "enDescribe").getValue() != null)
                        {
/* 304*/                    String enDescribe = (String)tblMainPlan.getCell(i, "enDescribe").getValue();
/* 305*/                    entry.setDescribe(enDescribe);
                        }
/* 307*/                if(tblMainPlan.getCell(i, "theme").getValue() != null)
                        {
/* 308*/                    String theme = (String)tblMainPlan.getCell(i, "theme").getValue();
/* 309*/                    entry.setTheme(theme);
                        }
/* 311*/                entry.getSellPlanEntry().add(sellPlanInfo);
/* 312*/                editData.getEntry().add(entry);
                    }
                }

            }

            private void setMY()
                throws Exception
            {
/* 318*/        int year = 0;
/* 319*/        int month = 0;
/* 320*/        if(txtPlanYear.getValue() instanceof Integer)
/* 321*/            year = ((Integer)txtPlanYear.getValue()).intValue();
/* 322*/        if(txtPlanYear.getValue() instanceof BigDecimal)
/* 323*/            year = ((BigDecimal)txtPlanYear.getValue()).intValue();
/* 324*/        month = ((Integer)kDPlanMonth.getValue()).intValue();
/* 325*/        MarketPlanInfo info = getEnterpriseNew();
/* 326*/        if(info == null)
                {
/* 327*/            txtVersion.setText("V1.0");
/* 328*/            getName();
/* 329*/            return;
                }
/* 331*/        if(info.getPlanYear() > year || info.getPlanYear() == year && info.getPlanMonth() > month)
                {
/* 333*/            FDCMsgBox.showError(this, "\u5F53\u524D\u5E74\u6708\u6216\u4E4B\u540E\u5DF2\u6709\u8BA1\u5212\uFF0C\u4E0D\u80FD\u5728\u6B64\u5E74\u6708\u65B0\u589E\u4F01\u5212\u8BA1\u5212");
/* 334*/            detachListeners();
/* 335*/            txtPlanYear.setValue(new Integer(info.getPlanYear()));
/* 336*/            attachListeners();
/* 338*/            kDPlanMonth.setValue(new Integer(info.getPlanMonth()));
                } else
                {
/* 341*/            tblMainPlan.removeRows();
/* 342*/            editData.getEntry().clear();
/* 343*/            if(info.getPlanYear() == year && info.getPlanMonth() == month)
                    {
/* 344*/                txtVersion.setText((new StringBuilder("V")).append(getVersionInt(info.getVersion())).append(".0").toString());
/* 345*/                for(int i = 0; i < info.getEntry().size(); i++)
/* 346*/                    editData.getEntry().add(info.getEntry().get(i));

                    } else
                    {
/* 349*/                txtVersion.setText("V1.0");
/* 350*/                for(int i = 0; i < info.getEntry().size(); i++)
/* 351*/                    if(!info.getEntry().get(i).getState().equals(ThemeEnum.Finish) && !info.getEntry().get(i).getState().equals(ThemeEnum.Canceled))
/* 354*/                        editData.getEntry().add(info.getEntry().get(i));

                    }
/* 357*/            loadEntry(editData.getEntry());
/* 358*/            getName();
                }
            }

            protected void txtPlanYear_dataChanged(DataChangeEvent e)
                throws Exception
            {
/* 362*/        setMY();
            }

            protected void kDPlanMonth_stateChanged(ChangeEvent e)
                throws Exception
            {
/* 368*/        setMY();
            }

            public String getName()
            {
/* 374*/        int year = 0;
/* 375*/        int month = 0;
/* 376*/        String Names = null;
/* 377*/        if(txtPlanYear.getValue() instanceof Integer)
/* 378*/            year = ((Integer)txtPlanYear.getValue()).intValue();
/* 379*/        if(txtPlanYear.getValue() instanceof BigDecimal)
/* 380*/            year = ((BigDecimal)txtPlanYear.getValue()).intValue();
/* 381*/        month = ((Integer)kDPlanMonth.getValue()).intValue();
/* 382*/        SellProjectInfo sell = (SellProjectInfo)prmtSellProject.getValue();
/* 384*/        try
                {
/* 384*/            if(sell != null)
                    {
/* 385*/                SellProjectInfo sellInfo = SellProjectFactory.getRemoteInstance().getSellProjectInfo(new ObjectUuidPK(sell.getId().toString()));
/* 386*/                String name = sellInfo.getName();
/* 387*/                String version = txtVersion.getText();
/* 388*/                Names = (new StringBuilder(String.valueOf(name))).append(year).append("\u5E74").append(month).append("\u6708").append("\u8425\u9500\u8D39\u7528\u8BA1\u5212").append(version).toString();
                    }
                }
/* 390*/        catch(Exception e)
                {
/* 391*/            e.printStackTrace();
                }
/* 393*/        txtName.setText(Names);
/* 394*/        return Names;
            }

            public void loadEntry(MarketPlanEntryCollection entry)
            {
/* 400*/        tblMainPlan.removeRows();
/* 401*/        MarketPlanEntryCollection enterEntryColl = entry;
/* 402*/        CRMHelper.sortCollection(enterEntryColl, "seq", true);
/* 403*/        for(int i = 0; i < enterEntryColl.size(); i++)
                {
/* 404*/            MarketPlanEntryInfo planEntryInfo = enterEntryColl.get(i);
/* 406*/            MarketPlanEntrySellPlanEntryCollection sellCol = planEntryInfo.getSellPlanEntry();
/* 407*/            CRMHelper.sortCollection(sellCol, "seq", true);
/* 408*/            for(int j = 0; j < sellCol.size(); j++)
                    {
/* 409*/                IRow row = tblMainPlan.addRow();
/* 410*/                MarketPlanEntrySellPlanEntryInfo sellInfo = sellCol.get(j);
/* 411*/                row.setUserObject(sellInfo);
/* 413*/                ThemeEnum themeState = planEntryInfo.getState();
/* 414*/                row.getCell("theme").setValue(planEntryInfo.getTheme());
/* 415*/                row.getCell("theme").setUserObject(planEntryInfo);
/* 416*/                row.getCell("themeState").setValue(planEntryInfo.getState());
/* 417*/                row.getCell("enDescribe").setValue(planEntryInfo.getDescribe());
/* 418*/                row.getCell("id").setValue(planEntryInfo.getId());
/* 420*/                if(ThemeEnum.Finish.equals(themeState) || ThemeEnum.Canceled.equals(themeState))
                        {
/* 421*/                    row.getCell("theme").getStyleAttributes().setLocked(true);
/* 422*/                    row.getCell("enDescribe").getStyleAttributes().setLocked(true);
                        }
/* 424*/                ThemeEnum entryState = sellInfo.getState();
/* 425*/                if(ThemeEnum.Finish.equals(entryState) || ThemeEnum.Canceled.equals(entryState))
                        {
/* 426*/                    row.getCell("proceeding").getStyleAttributes().setLocked(true);
/* 427*/                    row.getCell("subject").getStyleAttributes().setLocked(true);
/* 428*/                    row.getCell("classify").getStyleAttributes().setLocked(true);
/* 429*/                    row.getCell("mediaName").getStyleAttributes().setLocked(true);
/* 430*/                    row.getCell("startTime").getStyleAttributes().setLocked(true);
/* 431*/                    row.getCell("endTime").getStyleAttributes().setLocked(true);
/* 432*/                    row.getCell("quantity").getStyleAttributes().setLocked(true);
/* 433*/                    row.getCell("planCost").getStyleAttributes().setLocked(true);
/* 434*/                    row.getCell("remark").getStyleAttributes().setLocked(true);
/* 436*/                    row.getCell("proceeding").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 437*/                    row.getCell("subject").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 438*/                    row.getCell("classify").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 439*/                    row.getCell("mediaName").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 440*/                    row.getCell("startTime").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 441*/                    row.getCell("endTime").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 442*/                    row.getCell("quantity").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 443*/                    row.getCell("planCost").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 444*/                    row.getCell("remark").getStyleAttributes().setBackground(new Color(245, 245, 245));
                        }
/* 446*/                row.getCell("entryid").setValue(sellInfo.getId());
/* 447*/                row.getCell("proceeding").setValue(sellInfo.getProceeding());
/* 448*/                row.getCell("entryState").setValue(sellInfo.getState());
/* 449*/                row.getCell("subject").setValue(sellInfo.getSubject());
/* 450*/                row.getCell("classify").setValue(sellInfo.getClassify());
/* 451*/                row.getCell("mediaName").setValue(sellInfo.getMediaName());
/* 452*/                row.getCell("startTime").setValue(sellInfo.getStartTime());
/* 453*/                row.getCell("endTime").setValue(sellInfo.getEndTime());
/* 454*/                row.getCell("quantity").setValue(Integer.valueOf(sellInfo.getQuantity()));
/* 455*/                row.getCell("planCost").setValue(sellInfo.getPlanCost());
/* 456*/                row.getCell("remark").setValue(sellInfo.getRemark());
                    }

                }

/* 459*/        tblMainPlan.getColumn("themeState").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 460*/        tblMainPlan.getColumn("entryState").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 461*/        tblMainPlan.getColumn("subject").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 462*/        tblMainPlan.getColumn("classify").getStyleAttributes().setBackground(new Color(245, 245, 245));
/* 464*/        mergerTable(tblMainPlan, new String[] {
/* 464*/            "id"
                }, new String[] {
/* 464*/            "theme", "themeState", "enDescribe"
                });
            }

            public static BigDecimal EADD(KDTable kdtEntrys, String name1)
            {
/* 482*/        BigDecimal count1 = new BigDecimal(0);
/* 483*/        BigDecimal sum = new BigDecimal(0);
/* 484*/        for(int i = 0; i < kdtEntrys.getRowCount(); i++)
/* 486*/            if(kdtEntrys.getRow(i).getCell(name1) != null && kdtEntrys.getRow(i).getCell(name1).getValue() != null && !kdtEntrys.getRow(i).getCell("themeState").getValue().equals(ThemeEnum.Canceled))
/* 488*/                count1 = count1.add((BigDecimal)kdtEntrys.getRow(i).getCell(name1).getValue());

/* 491*/        sum = count1;
/* 492*/        return sum;
            }

            protected void tblMainPlan_editStopped(KDTEditEvent e)
                throws Exception
            {
/* 498*/        txtTotalAmount.setValue(EADD(tblMainPlan, "planCost"));
/* 500*/        int rowIndex = e.getRowIndex();
/* 501*/        String keyName = tblMainPlan.getColumnKey(e.getColIndex());
/* 502*/        if("theme".equals(keyName))
                {
/* 503*/            for(int i = 0; i < tblMainPlan.getRowCount(); i++)
                    {
/* 504*/                IRow rmrow = tblMainPlan.getRow(i);
/* 505*/                if(rmrow.getCell("id").getValue().equals(tblMainPlan.getRow(rowIndex).getCell("id").getValue()))
/* 506*/                    rmrow.getCell("theme").setValue(tblMainPlan.getRow(rowIndex).getCell("theme").getValue());
                    }

                } else
/* 509*/        if("enDescribe".equals(keyName))
                {
/* 510*/            for(int i = 0; i < tblMainPlan.getRowCount(); i++)
                    {
/* 511*/                IRow rmrow = tblMainPlan.getRow(i);
/* 512*/                if(rmrow.getCell("id").getValue().equals(tblMainPlan.getRow(rowIndex).getCell("id").getValue()))
/* 513*/                    rmrow.getCell("enDescribe").setValue(tblMainPlan.getRow(rowIndex).getCell("enDescribe").getValue());
                    }

                } else
/* 516*/        if("subject".equals(keyName))
                {
/* 517*/            if(tblMainPlan.getCell(rowIndex, "subject").getValue() != null)
                    {
/* 518*/                CostFeeInfo subject = (CostFeeInfo)tblMainPlan.getCell(rowIndex, "subject").getValue();
                    }
/* 525*/            if(e.getOldValue() != null && !e.getOldValue().equals(tblMainPlan.getCell(rowIndex, "subject").getValue()))
                    {
/* 526*/                tblMainPlan.getCell(rowIndex, "classify").setValue(null);
/* 527*/                tblMainPlan.getCell(rowIndex, "mediaName").setValue(null);
                    }
                } else
/* 529*/        if("classify".equals(keyName))
                {
/* 530*/            if(tblMainPlan.getCell(rowIndex, "classify").getValue() != null)
                    {
/* 531*/                ChannelTypeTreeInfo classifyInfo = (ChannelTypeTreeInfo)tblMainPlan.getCell(rowIndex, "classify").getValue();
/* 532*/                CostFeeInfo subjectInfo = CostFeeFactory.getRemoteInstance().getCostFeeInfo(new ObjectUuidPK(classifyInfo.getCsotaccount().getId()));
/* 533*/                tblMainPlan.getCell(rowIndex, "subject").setValue(subjectInfo);
/* 534*/                if(tblMainPlan.getCell(rowIndex, "mediaName").getValue() != null)
                        {
/* 535*/                    ChannelTypeInfo mediaName = (ChannelTypeInfo)tblMainPlan.getCell(rowIndex, "mediaName").getValue();
/* 536*/                    ChannelTypeCollection col = ChannelTypeFactory.getRemoteInstance().getChannelTypeCollection((new StringBuilder("select * from where treeid='")).append(classifyInfo.getId()).append("' and id='").append(mediaName.getId()).append("'").toString());
/* 537*/                    if(col.size() > 0)
/* 538*/                        tblMainPlan.getCell(rowIndex, "mediaName").setValue(col.get(0));
/* 540*/                    else
/* 540*/                        tblMainPlan.getCell(rowIndex, "mediaName").setValue(null);
                        }
                    }
                } else
/* 544*/        if("mediaName".equals(keyName))
                {
/* 545*/            if(tblMainPlan.getCell(rowIndex, "mediaName").getValue() != null)
                    {
/* 546*/                ChannelTypeInfo mediaName = (ChannelTypeInfo)tblMainPlan.getCell(rowIndex, "mediaName").getValue();
/* 547*/                String classifyId = mediaName.getTreeid().getId().toString();
/* 548*/                ChannelTypeTreeInfo classifyInfo = ChannelTypeTreeFactory.getRemoteInstance().getChannelTypeTreeInfo(new ObjectUuidPK(classifyId));
/* 549*/                tblMainPlan.getCell(rowIndex, "classify").setValue(classifyInfo);
/* 550*/                CostFeeInfo subjectInfo = CostFeeFactory.getRemoteInstance().getCostFeeInfo(new ObjectUuidPK(classifyInfo.getCsotaccount().getId().toString()));
/* 551*/                tblMainPlan.getCell(rowIndex, "subject").setValue(subjectInfo);
                    }
                } else
/* 553*/        if("startTime".equals(keyName))
                {
/* 554*/            Date startDate = (Date)tblMainPlan.getRow(rowIndex).getCell("startTime").getValue();
/* 555*/            Date endDate = (Date)tblMainPlan.getRow(rowIndex).getCell("endTime").getValue();
/* 556*/            if(startDate != null && endDate != null && startDate.compareTo(endDate) > 0)
                    {
/* 558*/                tblMainPlan.getRow(rowIndex).getCell("startTime").setValue(null);
/* 559*/                FDCMsgBox.showWarning(this, "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u5C0F\u4E8E\u5F00\u59CB\u65F6\u95F4\uFF01");
/* 560*/                SysUtil.abort();
                    }
                } else
/* 563*/        if("endTime".equals(keyName))
                {
/* 564*/            Date startDate = (Date)tblMainPlan.getRow(rowIndex).getCell("startTime").getValue();
/* 565*/            Date endDate = (Date)tblMainPlan.getRow(rowIndex).getCell("endTime").getValue();
/* 566*/            if(startDate != null && endDate != null && startDate.compareTo(endDate) > 0)
                    {
/* 568*/                tblMainPlan.getRow(rowIndex).getCell("endTime").setValue(null);
/* 569*/                FDCMsgBox.showWarning(this, "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u5C0F\u4E8E\u5F00\u59CB\u65F6\u95F4\uFF01");
/* 570*/                SysUtil.abort();
                    }
                }
            }

            public void actionChange_actionPerformed(ActionEvent e)
                throws Exception
            {
/* 581*/        int rowIndex = tblMainPlan.getSelectManager().getActiveRowIndex();
/* 582*/        if(rowIndex == -1)
/* 583*/            return;
/* 585*/        IRow row = tblMainPlan.getRow(rowIndex);
/* 586*/        ThemeEnum themState = (ThemeEnum)row.getCell("themeState").getValue();
/* 587*/        ThemeEnum updateState = null;
/* 588*/        if(themState.equals(ThemeEnum.Canceled))
                {
/* 590*/            updateState = ThemeEnum.UnStarted;
/* 591*/            row.getCell("themeState").setValue(updateState);
/* 592*/            btnChange.setText("\u53D6\u6D88\u4E3B\u9898");
                } else
/* 593*/        if(themState.equals(ThemeEnum.UnStarted))
                {
/* 594*/            updateState = ThemeEnum.Canceled;
/* 595*/            row.getCell("themeState").setValue(updateState);
/* 596*/            btnChange.setText("\u6FC0\u6D3B\u4E3B\u9898");
                } else
/* 597*/        if(themState.equals(ThemeEnum.Underway) || themState.equals(ThemeEnum.Finish))
                {
/* 598*/            MsgBox.showWarning(this, "\u5DF2\u5B8C\u6210\u6216\u8005\u8FDB\u884C\u4E2D\u7684\u4E3B\u9898\u4E0D\u80FD\u8FDB\u884C\u4E3B\u9898\u72B6\u6001\u53D8\u66F4!");
/* 599*/            return;
                }
/* 601*/        for(int i = 0; i < tblMainPlan.getRowCount(); i++)
                {
/* 602*/            IRow rmrow = tblMainPlan.getRow(i);
/* 603*/            if(rmrow.getCell("id").getValue().equals(row.getCell("id").getValue()))
/* 604*/                rmrow.getCell("themeState").setValue(updateState);
                }

/* 607*/        txtTotalAmount.setValue(EADD(tblMainPlan, "planCost"));
            }

            public void actionAddTheme_actionPerformed(ActionEvent e)
                throws Exception
            {
/* 615*/        IRow row = tblMainPlan.addRow();
/* 616*/        row.getCell("themeState").setValue(ThemeEnum.UnStarted);
/* 617*/        row.getCell("entryState").setValue(ThemeEnum.UnStarted);
/* 618*/        MarketPlanEntrySellPlanEntryInfo sellPlan = new MarketPlanEntrySellPlanEntryInfo();
/* 619*/        row.setUserObject(sellPlan);
/* 621*/        MarketPlanEntryInfo entry = new MarketPlanEntryInfo();
/* 622*/        entry.setId(BOSUuid.create(entry.getBOSType()));
/* 623*/        row.getCell("theme").setUserObject(entry);
/* 624*/        row.getCell("id").setValue(entry.getId());
/* 625*/        tblMainPlan.getSelectManager().select(row.getRowIndex(), 0);
            }

            public void actionDelTheme_actionPerformed(ActionEvent e)
                throws Exception
            {
/* 632*/        int rowIndex = tblMainPlan.getSelectManager().getActiveRowIndex();
/* 633*/        IRow row = tblMainPlan.getRow(rowIndex);
/* 634*/        if(rowIndex == -1)
                {
/* 635*/            MsgBox.showWarning(this, "\u8BF7\u9009\u4E2D\u4F01\u5212\u4E3B\u9898\u5220\u9664\uFF01");
/* 636*/            return;
                }
/* 638*/        if(row.getCell("themeState").getValue().equals(ThemeEnum.Finish) || row.getCell("themeState").getValue().equals(ThemeEnum.Underway))
                {
/* 639*/            MsgBox.showWarning(this, (new StringBuilder()).append(row.getCell("themeState").getValue()).append("\u7684\u4E3B\u9898\u4E0D\u80FD\u5220\u9664!").toString());
/* 640*/            return;
                }
/* 642*/        Set indexSet = new HashSet();
/* 643*/        for(int i = 0; i < tblMainPlan.getRowCount(); i++)
                {
/* 644*/            IRow rmrow = tblMainPlan.getRow(i);
/* 645*/            if(rmrow.getCell("id").getValue().equals(row.getCell("id").getValue()))
/* 646*/                indexSet.add(new Integer(i));
                }

/* 649*/        indexSet.add(new Integer(rowIndex));
/* 651*/        Integer indexArr[] = new Integer[indexSet.size()];
/* 652*/        Object indexObj[] = indexSet.toArray();
/* 653*/        System.arraycopy(((Object) (indexObj)), 0, indexArr, 0, indexArr.length);
/* 654*/        Arrays.sort(indexArr);
/* 655*/        if(indexArr == null)
/* 656*/            return;
/* 658*/        for(int i = indexArr.length - 1; i >= 0; i--)
                {
/* 659*/            int rm = Integer.parseInt(String.valueOf(indexArr[i]));
/* 660*/            tblMainPlan.removeRow(rm);
                }

/* 663*/        txtTotalAmount.setValue(EADD(tblMainPlan, "planCost"));
            }

            public void actionAddProceed_actionPerformed(ActionEvent e)
                throws Exception
            {
/* 672*/        super.actionAddProceed_actionPerformed(e);
/* 673*/        int rowIndex = tblMainPlan.getSelectManager().getActiveRowIndex();
/* 674*/        IRow prow = tblMainPlan.getRow(rowIndex);
/* 675*/        if(rowIndex == -1)
                {
/* 676*/            MsgBox.showWarning(this, "\u8BF7\u9009\u4E2D\u4F01\u5212\u4E3B\u9898\uFF01");
/* 677*/            return;
                }
/* 679*/        if(prow.getCell("themeState").getValue().equals(ThemeEnum.Canceled) || prow.getCell("themeState").getValue().equals(ThemeEnum.Finish))
                {
/* 680*/            MsgBox.showWarning(this, "\u5DF2\u5B8C\u6210\u6216\u8005\u5DF2\u53D6\u6D88\u7684\u4E3B\u9898\u4E0D\u80FD\u589E\u52A0\u4E8B\u9879!");
/* 681*/            return;
                } else
                {
/* 684*/            IRow row = tblMainPlan.addRow(rowIndex + 1);
/* 685*/            MarketPlanEntrySellPlanEntryInfo sellPlan = new MarketPlanEntrySellPlanEntryInfo();
/* 686*/            row.setUserObject(sellPlan);
/* 687*/            row.getCell("entryState").setValue(ThemeEnum.UnStarted);
/* 688*/            row.getCell("theme").setValue(prow.getCell("theme").getValue());
/* 689*/            row.getCell("theme").setUserObject(prow.getCell("theme").getUserObject());
/* 690*/            row.getCell("themeState").setValue(prow.getCell("themeState").getValue());
/* 691*/            row.getCell("enDescribe").setValue(prow.getCell("enDescribe").getValue());
/* 692*/            row.getCell("id").setValue(prow.getCell("id").getValue());
/* 693*/            mergerTable(tblMainPlan, new String[] {
/* 693*/                "id"
                    }, new String[] {
/* 693*/                "theme", "themeState", "enDescribe"
                    });
/* 694*/            return;
                }
            }

            public void actionDelProceed_actionPerformed(ActionEvent e)
                throws Exception
            {
/* 700*/        int rowIndex = tblMainPlan.getSelectManager().getActiveRowIndex();
/* 701*/        IRow row = tblMainPlan.getRow(rowIndex);
/* 702*/        if(rowIndex == -1)
                {
/* 703*/            MsgBox.showWarning(this, "\u8BF7\u9009\u4E2D\u4E8B\u9879\u5220\u9664\uFF01");
/* 704*/            return;
                }
/* 706*/        if(row.getCell("entryState").getValue().equals(ThemeEnum.Finish) || row.getCell("entryState").getValue().equals(ThemeEnum.Underway))
                {
/* 707*/            MsgBox.showWarning(this, (new StringBuilder()).append(row.getCell("entryState").getValue()).append("\u7684\u4E8B\u9879\u4E0D\u80FD\u5220\u9664!").toString());
/* 708*/            return;
                }
/* 710*/        if(tblMainPlan.getRow(rowIndex).getCell("themeState").getValue() == null || tblMainPlan.getRow(rowIndex).getCell("themeState").getValue().equals(ThemeEnum.UnStarted))
/* 711*/            tblMainPlan.removeRow(rowIndex);
/* 713*/        else
/* 713*/            tblMainPlan.getRow(rowIndex).getCell("entryState").setValue(ThemeEnum.Canceled);
/* 717*/        txtTotalAmount.setValue(EADD(tblMainPlan, "planCost"));
            }

            public static void mergerTable(KDTable table, String coloum[], String mergeColoum[])
            {
/* 722*/        int merger = 0;
/* 723*/        for(int i = 0; i < table.getRowCount(); i++)
/* 724*/            if(i > 0)
                    {
/* 725*/                boolean isMerge = true;
/* 726*/                for(int j = 0; j < coloum.length; j++)
                        {
/* 727*/                    Object curRow = table.getRow(i).getCell(coloum[j]).getValue();
/* 728*/                    Object lastRow = table.getRow(i - 1).getCell(coloum[j]).getValue();
/* 729*/                    if(getString(curRow).equals("") || getString(lastRow).equals("") || !getString(curRow).equals(getString(lastRow)))
                            {
/* 730*/                        isMerge = false;
/* 731*/                        merger = i;
                            }
                        }

/* 734*/                if(isMerge)
                        {
/* 735*/                    for(int j = 0; j < mergeColoum.length; j++)
/* 736*/                        table.getMergeManager().mergeBlock(merger, table.getColumnIndex(mergeColoum[j]), i, table.getColumnIndex(mergeColoum[j]));

                        }
                    }

            }

            private static String getString(Object value)
            {
/* 743*/        if(value == null)
/* 743*/            return "";
/* 744*/        if(value != null && value.toString().trim().equals(""))
/* 745*/            return "";
/* 747*/        else
/* 747*/            return value.toString();
            }

            public void filesType()
                throws Exception
            {
/* 755*/        tblMainPlan.checkParsed();
/* 756*/        tblMainPlan.getSelectManager().setSelectMode(1);
/* 759*/        KDComboBox tblMainPlan_themeState_TextField = new KDComboBox();
/* 760*/        tblMainPlan_themeState_TextField.setName("tblMainPlan_themeState_TextField");
/* 761*/        tblMainPlan_themeState_TextField.addItems(ThemeEnum.getEnumList().toArray());
/* 762*/        KDTDefaultCellEditor tblMainPlan_themeState_CellEditor = new KDTDefaultCellEditor(tblMainPlan_themeState_TextField);
/* 763*/        tblMainPlan.getColumn("themeState").setEditor(tblMainPlan_themeState_CellEditor);
/* 766*/        KDBizPromptBox f7Box = new KDBizPromptBox();
/* 767*/        f7Box.setDisplayFormat("$name$");
/* 768*/        f7Box.setEditFormat("$number$");
/* 769*/        f7Box.setCommitFormat("$number$");
/* 770*/        f7Box.setQueryInfo("com.kingdee.eas.crm.base.app.CostFeeQuery");
/* 772*/        EntityViewInfo evi = new EntityViewInfo();
/* 773*/        FilterInfo filter = new FilterInfo();
/* 777*/        evi.setFilter(filter);
/* 778*/        f7Box.setEntityViewInfo(evi);
/* 780*/        com.kingdee.bos.ctrl.kdf.util.editor.ICellEditor f7Editor = new KDTDefaultCellEditor(f7Box);
/* 781*/        tblMainPlan.getColumn("subject").setEditor(f7Editor);
/* 784*/        String classify = "com.kingdee.eas.crm.market.app.ChannelTypeTreeQuery";
/* 785*/        EntityViewInfo classifyView = new EntityViewInfo();
/* 786*/        FilterInfo classifyfilter = new FilterInfo();
/* 787*/        classifyView.setFilter(classifyfilter);
/* 788*/        com.kingdee.bos.ctrl.kdf.util.editor.ICellEditor f7classify = new KDTDefaultCellEditor(TableUtils.getF7productType(classify, classifyView));
/* 789*/        tblMainPlan.getColumn("classify").setEditor(f7classify);
/* 793*/        f7Box = new KDBizPromptBox();
/* 794*/        evi = new EntityViewInfo();
/* 795*/        filter = new FilterInfo();
/* 797*/        filter.getFilterItems().add(new FilterItemInfo("statrusing", Boolean.TRUE));
/* 798*/        filter.getFilterItems().add(new FilterItemInfo("CU.id", SysContext.getSysContext().getCurrentCtrlUnit().getId().toString()));
/* 799*/        evi.setFilter(filter);
/* 801*/        HashMap ctx = new HashMap();
/* 802*/        ctx.put("EntityViewInfo", evi);
/* 803*/        ctx.put("EnableMultiSelection", new Boolean(false));
/* 804*/        ctx.put("HasCUDefaultFilter", new Boolean(true));
/* 807*/        ChannelTypeListUI ctlistUI = new ChannelTypeListUI();
/* 808*/        ctlistUI.setF7Use(true, ctx);
/* 809*/        ctlistUI.getUIToolBar().setVisible(false);
/* 810*/        ctlistUI.getUIMenuBar().setVisible(false);
/* 811*/        f7Box.setSelector(ctlistUI);
/* 812*/        f7Editor = new KDTDefaultCellEditor(f7Box);
/* 813*/        tblMainPlan.getColumn("mediaName").setEditor(f7Editor);
/* 816*/        KDDatePicker tblMainPlan_startTime_PromptBox = new KDDatePicker();
/* 817*/        tblMainPlan_startTime_PromptBox.setName("tblMainPlan_startTime_PromptBox");
/* 818*/        tblMainPlan_startTime_PromptBox.setVisible(true);
/* 819*/        tblMainPlan_startTime_PromptBox.setEnabled(true);
/* 820*/        KDTDefaultCellEditor tblMainPlan_startTime_CellEditor = new KDTDefaultCellEditor(tblMainPlan_startTime_PromptBox);
/* 821*/        tblMainPlan.getColumn("startTime").setEditor(tblMainPlan_startTime_CellEditor);
/* 824*/        KDDatePicker tblMainPlan_endTime_PromptBox = new KDDatePicker();
/* 825*/        tblMainPlan_endTime_PromptBox.setName("tblMainPlan_endTime_PromptBox");
/* 826*/        tblMainPlan_endTime_PromptBox.setVisible(true);
/* 827*/        tblMainPlan_endTime_PromptBox.setEnabled(true);
/* 828*/        KDTDefaultCellEditor tblMainPlan_endTime_CellEditor = new KDTDefaultCellEditor(tblMainPlan_endTime_PromptBox);
/* 829*/        tblMainPlan.getColumn("endTime").setEditor(tblMainPlan_endTime_CellEditor);
/* 831*/        com.kingdee.bos.ctrl.kdf.util.editor.ICellEditor integerEditor = TableUtils.getCellIntegerNumberEdit();
/* 832*/        tblMainPlan.getColumn("quantity").setEditor(integerEditor);
/* 833*/        tblMainPlan.getColumn("quantity").getStyleAttributes().setHorizontalAlign(com.kingdee.bos.ctrl.kdf.util.style.Styles.HorizontalAlignment.RIGHT);
/* 834*/        txtPlanYear.setPrecision(0);
/* 836*/        com.kingdee.bos.ctrl.kdf.util.editor.ICellEditor bigDecimalEditor = CommerceHelper.getKDFormattedTextDecimalEditor();
/* 837*/        tblMainPlan.getColumn("planCost").setEditor(bigDecimalEditor);
/* 838*/        tblMainPlan.getColumn("planCost").getStyleAttributes().setHorizontalAlign(com.kingdee.bos.ctrl.kdf.util.style.Styles.HorizontalAlignment.RIGHT);
            }

            protected void attachListeners()
            {
/* 841*/        addDataChangeListener(kDPlanMonth);
/* 842*/        addDataChangeListener(txtPlanYear);
            }

            protected void detachListeners()
            {
/* 845*/        removeDataChangeListener(kDPlanMonth);
/* 846*/        removeDataChangeListener(txtPlanYear);
            }

            protected void removeDataChangeListener(JComponent com)
            {
///* 849*/        java.util.EventListener listeners[] = (java.util.EventListener[])null;
///* 851*/        if(com instanceof KDPromptBox)
//                {
///* 852*/            listeners = com.getListeners(com.kingdee.bos.ctrl.swing.event.DataChangeListener);
///* 853*/            for(int i = 0; i < listeners.length; i++)
///* 854*/                ((KDPromptBox)com).removeDataChangeListener((DataChangeListener)listeners[i]);
//
//                } else
///* 856*/        if(com instanceof KDFormattedTextField)
//                {
///* 857*/            listeners = com.getListeners(com/kingdee/bos/ctrl/swing/event/DataChangeListener);
///* 858*/            for(int i = 0; i < listeners.length; i++)
///* 859*/                ((KDFormattedTextField)com).removeDataChangeListener((DataChangeListener)listeners[i]);
//
//                } else
///* 861*/        if(com instanceof KDDatePicker)
//                {
///* 862*/            listeners = com.getListeners(com/kingdee/bos/ctrl/swing/event/DataChangeListener);
///* 863*/            for(int i = 0; i < listeners.length; i++)
///* 864*/                ((KDDatePicker)com).removeDataChangeListener((DataChangeListener)listeners[i]);
//
//                } else
///* 866*/        if(com instanceof KDComboBox)
//                {
///* 867*/            listeners = com.getListeners(java/awt/event/ItemListener);
///* 868*/            for(int i = 0; i < listeners.length; i++)
///* 869*/                ((KDComboBox)com).removeItemListener((ItemListener)listeners[i]);
//
//                } else
///* 871*/        if(com instanceof KDSpinner)
//                {
///* 872*/            listeners = com.getListeners(javax/swing/event/ChangeListener);
///* 873*/            for(int i = 0; i < listeners.length; i++)
///* 874*/                ((KDSpinner)com).removeChangeListener((ChangeListener)listeners[i]);
//
//                }
///* 877*/        if(listeners != null && listeners.length > 0)
///* 878*/            listenersMap.put(com, listeners);
            }

            protected void addDataChangeListener(JComponent com)
            {
/* 882*/        java.util.EventListener listeners[] = (java.util.EventListener[])listenersMap.get(com);
/* 884*/        if(listeners != null && listeners.length > 0)
/* 885*/            if(com instanceof KDPromptBox)
                    {
/* 886*/                for(int i = 0; i < listeners.length; i++)
/* 887*/                    ((KDPromptBox)com).addDataChangeListener((DataChangeListener)listeners[i]);

                    } else
/* 889*/            if(com instanceof KDFormattedTextField)
                    {
/* 890*/                for(int i = 0; i < listeners.length; i++)
/* 891*/                    ((KDFormattedTextField)com).addDataChangeListener((DataChangeListener)listeners[i]);

                    } else
/* 893*/            if(com instanceof KDDatePicker)
                    {
/* 894*/                for(int i = 0; i < listeners.length; i++)
/* 895*/                    ((KDDatePicker)com).addDataChangeListener((DataChangeListener)listeners[i]);

                    } else
/* 897*/            if(com instanceof KDComboBox)
                    {
/* 898*/                for(int i = 0; i < listeners.length; i++)
/* 899*/                    ((KDComboBox)com).addItemListener((ItemListener)listeners[i]);

                    } else
/* 901*/            if(com instanceof KDSpinner)
                    {
/* 902*/                for(int i = 0; i < listeners.length; i++)
/* 903*/                    ((KDSpinner)com).addChangeListener((ChangeListener)listeners[i]);

                    }
            }

            protected ICoreBase getBizInterface()
                throws Exception
            {
/* 909*/        return MarketPlanFactory.getRemoteInstance();
            }

            protected KDTable getDetailTable()
            {
/* 913*/        return null;
            }

            protected KDTextField getNumberCtrl()
            {
/* 917*/        return txtNumber;
            }

            protected IObjectValue createNewData()
            {
/* 925*/        sellProjectId = (String)getUIContext().get("sellProjectId");
/* 926*/        MarketPlanInfo info = getEnterpriseNew();
/* 927*/        if(sellProjectId != null)
                {
/* 928*/            if(info == null)
/* 929*/                info = new MarketPlanInfo();
/* 932*/            try
                    {
/* 932*/                SellInfo = SellProjectFactory.getRemoteInstance().getSellProjectInfo(new ObjectUuidPK(sellProjectId));
/* 933*/                BOSUuid id = SellInfo.getOrgUnit().getId();
/* 934*/                fullInfo = FullOrgUnitFactory.getRemoteInstance().getFullOrgUnitInfo(new ObjectUuidPK(id));
/* 935*/                info.setSellProject(SellInfo);
/* 936*/                info.setOrgUnit(fullInfo);
/* 937*/                if(info.getId() == null)
                        {
/* 938*/                    now = SysUtil.getAppServerTime(null);
/* 939*/                    Calendar cal = Calendar.getInstance();
/* 940*/                    cal.setTime(now);
/* 941*/                    info.setPlanMonth(cal.get(2) + 1);
/* 942*/                    info.setPlanYear(cal.get(1));
                        }
                    }
/* 944*/            catch(Exception e)
                    {
/* 945*/                e.printStackTrace();
                    }
                }
/* 948*/        if(info == null)
/* 949*/            info = new MarketPlanInfo();
/* 951*/        String version = info.getVersion();
/* 952*/        info.setVersion((new StringBuilder("V")).append(getVersionInt(version)).append(".0").toString());
/* 954*/        info.setName((new StringBuilder(String.valueOf(info.getSellProject().getName()))).append(info.getPlanYear()).append("\u5E74").append(info.getPlanMonth()).append("\u6708").append("\u8425\u9500\u8D39\u7528\u8BA1\u5212").append(info.getVersion()).toString());
/* 955*/        info.setId(null);
/* 956*/        info.setUseing(false);
/* 957*/        info.setNumber(null);
/* 958*/        info.setState(FDCBillStateEnum.SAVED);
/* 959*/        info.setAuditor(null);
/* 960*/        info.setAuditTime(null);
/* 961*/        info.setCreateTime(null);
/* 962*/        info.setCreator(SysContext.getSysContext().getCurrentUserInfo());
/* 964*/        MarketPlanInfo newInfo = getEnterpriseNewVersion();
/* 965*/        newInfo.setSellProject(SellInfo);
/* 966*/        newInfo.setOrgUnit(fullInfo);
/* 967*/        int v1 = getVersionInt(version);
/* 968*/        int v2 = getVersionInt(newInfo.getVersion());
/* 969*/        if(v1 < v2)
                {
/* 971*/            info = newInfo;
/* 972*/            setOprtState("EDIT");
/* 973*/            isWarning = true;
                }
/* 975*/        info.setCU(SysContext.getSysContext().getCurrentCtrlUnit());
/* 976*/        return info;
            }

            public int getVersionInt(String version)
            {
/* 982*/        int v = 1;
/* 983*/        if(version != null)
                {
/* 984*/            int index = version.indexOf("V");
/* 985*/            v = (new BigDecimal(version.substring(index + 1))).intValue() + 1;
                }
/* 987*/        return v;
            }

            public MarketPlanInfo getEnterpriseNewVersion()
            {
/* 993*/        MarketPlanInfo info = new MarketPlanInfo();
/* 994*/        EntityViewInfo viewInfo = new EntityViewInfo();
/* 995*/        FilterInfo filter = new FilterInfo();
/* 996*/        filter.getFilterItems().add(new FilterItemInfo("sellProject.id", sellProjectId));
/* 997*/        viewInfo.setFilter(filter);
/* 998*/        viewInfo.setSelector(getSelectors());
/* 999*/        MarketPlanCollection coll = null;
/*1001*/        try
                {
/*1001*/            coll = MarketPlanFactory.getRemoteInstance().getMarketPlanCollection(viewInfo);
/*1002*/            CRMHelper.sortCollection(coll, new String[] {
/*1002*/                "planYear", "planMonth", "version"
                    }, false);
                }
/*1003*/        catch(BOSException e)
                {
/*1004*/            e.printStackTrace();
                }
/*1006*/        if(coll.size() > 0)
/*1007*/            info = coll.get(0);
/*1009*/        return info;
            }

            public MarketPlanInfo getEnterpriseNew()
            {
/*1015*/        MarketPlanInfo info = null;
/*1016*/        EntityViewInfo viewInfo = new EntityViewInfo();
/*1017*/        FilterInfo filter = new FilterInfo();
/*1018*/        filter.getFilterItems().add(new FilterItemInfo("sellProject.id", sellProjectId));
/*1019*/        filter.getFilterItems().add(new FilterItemInfo("state", "4AUDITTED"));
/*1020*/        filter.getFilterItems().add(new FilterItemInfo("useing", Boolean.TRUE));
/*1021*/        viewInfo.setFilter(filter);
/*1022*/        viewInfo.setSelector(getSelectors());
/*1023*/        MarketPlanCollection coll = null;
/*1025*/        try
                {
/*1025*/            coll = MarketPlanFactory.getRemoteInstance().getMarketPlanCollection(viewInfo);
                }
/*1026*/        catch(BOSException e)
                {
/*1027*/            e.printStackTrace();
                }
/*1029*/        if(coll != null && coll.size() > 0)
                {
/*1030*/            info = coll.get(0);
/*1031*/            MarketPlanEntryCollection rmcol = new MarketPlanEntryCollection();
/*1032*/            for(int i = 0; i < info.getEntry().size(); i++)
                    {
/*1033*/                MarketPlanEntryInfo entry = info.getEntry().get(i);
/*1037*/                entry.setId(BOSUuid.create(entry.getBOSType()));
/*1038*/                for(int j = 0; j < entry.getSellPlanEntry().size(); j++)
/*1039*/                    entry.getSellPlanEntry().get(j).setId(null);

                    }

/*1043*/            for(int i = 0; i < rmcol.size(); i++)
/*1044*/                info.getEntry().remove(rmcol.get(i));

                }
/*1047*/        return info;
            }

            protected void tblMainPlan_tableClicked(KDTMouseEvent e)
                throws Exception
            {
/*1053*/        int rowIndex = tblMainPlan.getSelectManager().getActiveRowIndex();
/*1054*/        if(rowIndex == -1)
/*1055*/            return;
/*1057*/        IRow row = tblMainPlan.getRow(rowIndex);
/*1058*/        ThemeEnum themState = (ThemeEnum)row.getCell("themeState").getValue();
/*1059*/        if(themState.equals(ThemeEnum.Canceled))
/*1060*/            btnChange.setText("\u6FC0\u6D3B\u4E3B\u9898");
/*1061*/        else
/*1061*/        if(themState.equals(ThemeEnum.UnStarted))
/*1062*/            btnChange.setText("\u53D6\u6D88\u4E3B\u9898");
/*1064*/        if(e.getColIndex() == tblMainPlan.getColumnIndex("enDescribe"))
/*1066*/            if(ThemeEnum.Finish.equals(tblMainPlan.getRow(rowIndex).getCell("themeState").getValue()))
/*1067*/                showDialog(this, tblMainPlan, 250, 100, 2000, "VIEW");
/*1069*/            else
/*1069*/                showDialog(this, tblMainPlan, 250, 100, 2000, getOprtState());
            }

            public void showDialog(JComponent owner, KDTable table, int X, int Y, int len, String state)
            {
/*1076*/        int rowIndex = table.getSelectManager().getActiveRowIndex();
/*1077*/        int colIndex = table.getSelectManager().getActiveColumnIndex();
/*1078*/        ICell cell = table.getCell(rowIndex, colIndex);
/*1079*/        BasicView view = table.getViewManager().getView(5);
/*1080*/        Point p = view.getLocationOnScreen();
/*1081*/        Rectangle rect = view.getCellRectangle(rowIndex, colIndex);
/*1082*/        java.awt.Window parent = SwingUtilities.getWindowAncestor(owner);
                KDDetailedAreaDialog dialog;
/*1084*/        if(parent instanceof Dialog)
/*1086*/            dialog = new KDDetailedAreaDialog((Dialog)parent, X, Y, true);
/*1089*/        else
/*1089*/        if(parent instanceof Frame)
/*1090*/            dialog = new KDDetailedAreaDialog((Frame)parent, X, Y, true);
/*1093*/        else
/*1093*/            dialog = new KDDetailedAreaDialog(true);
/*1095*/        String vals = null;
/*1096*/        if(cell.getValue() == null)
/*1097*/            vals = "";
/*1099*/        else
/*1099*/            vals = cell.getValue().toString();
/*1101*/        dialog.setData(vals);
/*1102*/        dialog.setPRENTE_X(p.x + rect.x + rect.width);
/*1103*/        dialog.setPRENTE_Y(p.y + rect.y);
/*1104*/        dialog.setMaxLength(len);
/*1105*/        if(!state.equals("VIEW"))
/*1106*/            dialog.setEditable(true);
/*1108*/        else
/*1108*/            dialog.setEditable(false);
/*1110*/        dialog.show();
/*1111*/        cell.setValue(dialog.getData());
/*1112*/        for(int i = 0; i < tblMainPlan.getRowCount(); i++)
                {
/*1113*/            IRow rmrow = tblMainPlan.getRow(i);
/*1114*/            if(rmrow.getCell("id").getValue().equals(tblMainPlan.getRow(rowIndex).getCell("id").getValue()))
/*1115*/                rmrow.getCell("enDescribe").setValue(tblMainPlan.getRow(rowIndex).getCell("enDescribe").getValue());
                }

            }

            public static void setWrapFalse(ICell cell)
            {
/*1123*/        if(cell != null)
/*1124*/            cell.getStyleAttributes().setWrapText(true);
            }

            protected void setThisCellEditor(KDTable table, String colName, boolean isRequired, int maxLength)
            {
/*1129*/        KDDetailedArea area = new KDDetailedArea(280, 250);
/*1130*/        area.setRequired(isRequired);
/*1131*/        area.setEnabled(true);
/*1132*/        area.setMaxLength(maxLength);
/*1133*/        table.getColumn(colName).setEditor(new KDTDefaultCellEditor(area));
            }

            private boolean isWarning;
            SellProjectInfo SellInfo;
            FullOrgUnitInfo fullInfo;
            Date now;
            String sellProjectId;

}
